package com.lagou.sqlSession;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.pojo.Configuration;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream in) throws Exception {
        // 使用dom4j将配置文件解析，并存储到configuration中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(in);

        // 创建sqlSessionFactory
        SqlSessionFactory sqlSessionFactory = new DeafaultSqlSessionFactory(configuration);

        return sqlSessionFactory;
    }
}
